<?php
/**
 * 房源补漏
 */

namespace app\admin\controller;


use \app\admin\model\HouseTraps as HouseTrapsModel;
use app\common\controller\AdminController;
use think\Exception;

class HouseTraps extends AdminController {

    public $levelConfig = [
        1 => ['getlist','wherelist'],
        2 => ['deal'],
        4 => [],
        8 => []
    ];

    /**
     * 补漏列表
     * @return false|string
     */
    public function getList() {
        try {
            $params = $this->checkParams('page,long');
            if ($params === false) return $this->resErr();
            $list = HouseTrapsModel::getList($params);
            return $this->resData('success', $list);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 处理
     * @return false|string
     */
    public function deal() {
        try {
            $params = $this->checkParams('id');
            if ($params === false) return $this->resErr();
            HouseTrapsModel::deal($params);
            return $this->resData('处理成功', []);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 条件
     * @return false|string
     */
    public function whereList() {
        try {
            $params = $this->checkParams('');
            if ($params === false) return $this->resErr();
            $list = \app\admin\model\House::$whereList['source_type'];
            return $this->resData('success', compact('list'));
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }
}